window.JQ = function (url, data, showDialog, async) {

    if (window.android) {
        android.show()
    }
    return new Promise((res, rej) => {
        $.ajax({
            url: url,
            data: data,
            async: async == undefined ? true : false,
            success: function (e) {
                if (window.android && (showDialog == undefined || showDialog == null)) {
                    android.hide()
                }
                if (typeof (e) == 'string') {
                    res(JSON.parse(e))
                } else {
                    res(e)
                }
            },
            error: function (e) {
                if (window.android) {
                    android.hide()
                }
                alert("请求出错")
                if (typeof (e) == 'string') {
                    rej(JSON.parse(e))
                } else {
                    rej(e)
                }
            }
        })
    })

}